<!--
 * @Author: 刘霁雯
 * @Description: 消费记录
 -->
<template>
    <div>
        <cli-title-customer></cli-title-customer>
        <div class="orderList">
            <order-list :order-list="orderList"></order-list>
        </div>
    </div>

</template>

<script>
    import CliTitleCustomer from "../../../components/base/cliTitleCustomer";
    import OrderList from "../../../components/base/orderList";
    export default {
        components: {OrderList, CliTitleCustomer},
        data () {
            return {
                orderList:[]
            }
        },
        created () {
        },
        methods: {
            removeM:function(index_p){
                if(index_p < 0){
                    // this.arr.splice(0,this.arr.length);
                    this.arr = [];
                }else{
                    this.arr.splice(index_p,1);
                }
                this.clac();
            },
            add : function(index_p){
                this.arr[index_p].amount++;
                this.clac();
            },
            sub : function (index_p){

                if( this.arr[index_p].amount >= 1){

                    this.arr[index_p].amount--;
                    this.clac();
                }else{
                    if(confirm("您确定删除这条记录吗?")){
                        this.arr.splice(index_p,1);
                    }
                }
            },
            clac:function(){
                this.totalPrice = 0;
                var count = this.arr.length;
                for(var i = 0; i < count;i++){
                    this.totalPrice += this.arr[i].price * this.arr[i].amount;
                }
            }
        }
    }
</script>
<style scope>
    .orderList {
        position: absolute;
        right: 0;
        left: 0;
        top: 65px;
        margin: auto;
    }

</style>

